package cn.linjianhui.api.client.invoker.impl;

import com.alibaba.fastjson.JSONObject;
import cn.linjianhui.api.client.invoker.Serializer;

import java.util.List;

public class JsonSerializer implements Serializer {
    @Override
    public <T> T deserialize(String input, Class<T> returnType) {
        return JSONObject.parseObject(input, returnType);
    }

    @Override
    public <T> List<T> deserializeArray(String input, Class<T> returnType) {
        return JSONObject.parseArray(input, returnType);
    }

    @Override
    public String serialize(Object data) {
        return JSONObject.toJSONString(data);
    }
}
